package fr.upstlse.glre.client.espaceperso;

import net.mygwt.ui.client.Style;
import net.mygwt.ui.client.widget.ContentPanel;
import net.mygwt.ui.client.widget.ThemeSelector;
import net.mygwt.ui.client.widget.Viewport;
import net.mygwt.ui.client.widget.WidgetContainer;
import net.mygwt.ui.client.widget.layout.BorderLayout;
import net.mygwt.ui.client.widget.layout.BorderLayoutData;
import net.mygwt.ui.client.widget.layout.FillLayout;
import net.mygwt.ui.client.widget.layout.RowData;
import net.mygwt.ui.client.widget.layout.RowLayout;

import com.google.gwt.user.client.ui.HorizontalPanel;

import fr.upstlse.glre.client.espaceperso.panel.center.CenterPanel;
import fr.upstlse.glre.client.espaceperso.panel.north.NorthPanel;
import fr.upstlse.glre.client.espaceperso.panel.west.WestPanel;
import fr.upstlse.glre.client.vo.EtudiantVOGWT;

public class EspacePerso {

    
    private Viewport viewport;
    
    private ContentPanel westPanel;
    private ContentPanel centerPanel;
    private EtudiantVOGWT etudiant;

//	public WidgetContainer getPanel() {
//		return c;
//	}

    public void createWidget(EtudiantVOGWT pEtudiant) {
    	etudiant = pEtudiant;
//             c.setStyleName("my-border-layout");  
//             c.setLayout(new BorderLayout());  
//               
//             BorderLayoutData northData = new BorderLayoutData(Style.NORTH, 20);  
//             c.add(new NorthPanel().getNorthPanel(), northData);  
//             
//
//             BorderLayoutData westData = new BorderLayoutData(Style.WEST, 125, 75, 175);  
//             ContentPanel west = new ContentPanel(Style.HEADER);  
//             west.setText("Navigation");  
//             c.add(west, westData);  
//             west.add(new WestPanel().getWestPanel());
//             west.setHeight("800");
//               
//
//             ContentPanel center = new ContentPanel(Style.HEADER);
//             c.add(center, new BorderLayoutData(Style.CENTER));    
//             center.setText("Onglets de navigation");  
//             center.add(CenterPanel.getCenterPanel());
//             center.setHeight("800em");
        
            viewport = new Viewport();
            viewport.setStyleName("my-border-layout");
            
            viewport.setLayout(new RowLayout());
            viewport.setBorders(false);
            
            HorizontalPanel header = new HorizontalPanel();
            header.setStyleName("demo-header");
            header.add(new NorthPanel().getNorthPanel());
            
            WidgetContainer main = new WidgetContainer();
            main.setLayout(new BorderLayout());


            BorderLayoutData westData = new BorderLayoutData(Style.WEST, 200, 150, 300);
            westPanel = new ContentPanel(Style.HEADER);
            westPanel.setLayout(new FillLayout());
            westPanel.setText("Navigation");

            westPanel.add(new WestPanel().getWestPanel());

            centerPanel = new ContentPanel(Style.HEADER);
            centerPanel.getHeader().addWidget(new ThemeSelector());
            centerPanel.setLayout(new FillLayout());
            centerPanel.add(CenterPanel.getCenterPanel());

            main.add(westPanel, westData);
            main.add(centerPanel, new BorderLayoutData(Style.CENTER));

            viewport.add(header, new RowData(RowData.FILL_HORIZONTAL));
            viewport.add(main, new RowData(RowData.FILL_BOTH));
            viewport.layout();

            viewport.hideLoadingPanel("loading");
    }
    
    public void initWidget() {
    	CenterPanel.addProfil(etudiant);
    }
}